<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Storage;

use App\Models\ScenicDivination;

class divinationYzyItemResource extends JsonResource
{
    public function toArray($request)
    {
    	$resource = $this->resource;
    	
        $scenicDivination = ScenicDivination::query()->where('divination_id',$resource->id)->where('scenic_area_id',1)->first();

        return [
            'id' =>$resource->id,
        	'content' =>$scenicDivination->content ?? '',
	        'image'=>isset($scenicDivination->image) ? Storage::disk('public')->url($scenicDivination->image) : '',
            'profile'=>$scenicDivination->profile ?? '',
            'title'=>$resource->title,
            'uname'=>$scenicDivination->uname,
            'tag'=>$scenicDivination->tag,
            'hangye'=>$scenicDivination->hangye,
            'category'=>$scenicDivination->category,
            'cqgy'=>$scenicDivination->cqgy,
            'words'=>$scenicDivination->words,
            'direction'=>$scenicDivination->direction,
            'armoury'=>$scenicDivination->armoury,
            'dressing'=>$scenicDivination->dressing,
            'precautions'=>$scenicDivination->precautions,
            'symbol'=>$resource->symbol,
	        'created_at' => (string)$resource->created_at,
        ];
    }
}
